﻿using System.ComponentModel;
using RaytracerLib.RenderableObjects;
using RaytracerLib.UVMappers;

namespace Raytracer.PropertyGridDecorators
{
    public class PolynomialSurfaceProperties : RenderableObjectProperties
    {
        private PolynomialSurface m_poly;

        public PolynomialSurfaceProperties(PolynomialSurface a_sphere) :
            base(a_sphere)
        {
            m_poly = a_sphere;
        }

        [Category(Categories.POLYNOMIAL)]
        public string Equation
        {
            get
            {
                return m_poly.Equation;
            }
            set
            {
                m_poly.Equation = value;
            }
        }

        [Category(Categories.POLYNOMIAL)]
        [DisplayName("Parameter 1")]
        public string Parameter1
        {
            get
            {
                return m_poly.Parameter1;
            }
            set
            {
                m_poly.Parameter1 = value;
            }
        }

        [Category(Categories.POLYNOMIAL)]
        [DisplayName("Parameter 2")]
        public string Parameter2
        {
            get
            {
                return m_poly.Parameter2;
            }
            set
            {
                m_poly.Parameter2 = value;
            }
        }

        [Category(Categories.POLYNOMIAL)]
        [DisplayName("Parameter 3")]
        public string Parameter3
        {
            get
            {
                return m_poly.Parameter3;
            }
            set
            {
                m_poly.Parameter3 = value;
            }
        }

        [Category(Categories.POLYNOMIAL)]
        [TypeConverter(typeof(AABBConverter))]
        public AABBProperties LocalBoundBox
        {
            get
            {
                return new AABBProperties(() => m_poly.LocalBoundBox, (aabb) => m_poly.LocalBoundBox = aabb);
            }
            set
            {
                m_poly.LocalBoundBox = value.ToAABB();
            }
        }
    }
}